package cn.bupt.adt.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.bupt.adt.dao.autogenerate.UserAgreementMapper;
import cn.bupt.adt.entity.autogenerate.UserAgreement;
import cn.bupt.adt.entity.autogenerate.UserAgreementExample;
import cn.bupt.adt.service.IUserAgreementService;
@Service
public class UserAgreementService implements IUserAgreementService {
	
	@Autowired
	UserAgreementMapper userAgreementMapper;

	@Override
	public UserAgreement getUserAgreement() {
		List<UserAgreement> lists = userAgreementMapper.selectByExampleWithBLOBs(new UserAgreementExample());
		return lists.size() == 1?lists.get(0):null;
	}

	@Override
	public boolean updateUserAgreement(UserAgreement u) {
		if(userAgreementMapper.selectByPrimaryKey(u.getId())== null) 
			return userAgreementMapper.insert(u) == 1;
		else {
			return userAgreementMapper.updateByPrimaryKeySelective(u) == 1 ;
		}
	}

}
